﻿using CPPEI.BD.VMTool.Datas;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace CPPEI.BD.VMTool.Untils
{
    public class VMSolutionUntil
    {
        private static List<Item> _listVideoSource;
        private static List<VideoMatrixItem> _listVideoMatrixs;
        private static List<Solution> _listSolution;

        /// <summary>
        /// solution.xml文件的地址
        /// </summary>
        private static string _solutionFilePath
        {
            get
            {
                return GetSolutionFilePath();
            }
        }


        /// <summary>
        ///  根据方案名称获取对应的视频源和视频矩阵的对应关系
        /// </summary>
        /// <param name="name">方案名称</param>
        /// <param name="configFile">配置文件的路径</param>
        /// <returns></returns>
        public static List<Solution> GetListSolutionByName(string name)
        {
            if (System.IO.File.Exists(_solutionFilePath))
            {
                XmlDocument xmlDocument = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(_solutionFilePath, settings);
                xmlDocument.Load(reader);

                string rootName = "Solution-List";

                XmlNode rootNode = null;
                _listSolution = new List<Solution>();
                try
                {
                    ////根据xClassConfig的Name获取根节点
                    rootNode = xmlDocument.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return null;
                    }

                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;
                        if (name.Equals(xe.GetAttribute("Name").ToString()))
                        {
                            Solution solution = new Solution();
                            solution.Name = xe.GetAttribute("Name").ToString();
                            solution.Caption = xe.GetAttribute("Caption").ToString();
                            solution.Sortid = Convert.ToInt32(xe.GetAttribute("Sortid"));

                            // 得到solution节点的所有子节点
                            XmlNodeList childNodeList = xe.ChildNodes;
                            solution.Mapping = new List<Mapping>();

                            foreach (XmlNode node in childNodeList)
                            {
                                Mapping mapping = new Mapping();
                                XmlElement element = (XmlElement)node;
                                mapping.VideoMatrixId = element.GetAttribute("VideoMatrixId");
                                mapping.VideoSourceId = element.GetAttribute("VideoSourceId");
                                solution.Mapping.Add(mapping);
                            }
                            _listSolution.Add(solution);
                        }

                    }

                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    reader.Close();
                }

            }
            return _listSolution;
        }

        /// <summary>
        ///  根据类别名称获取对应的视频源和视频矩阵的对应关系
        /// </summary>
        /// <param name="name">方案名称</param>
        /// <param name="configFile">配置文件的路径</param>
        /// <returns></returns>
        public static List<Solution> GetListSolutionBySortid(string sortid)
        {
            if (System.IO.File.Exists(_solutionFilePath))
            {
                XmlDocument xmlDocument = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(_solutionFilePath, settings);
                xmlDocument.Load(reader);

                string rootName = "Solution-List";

                XmlNode rootNode = null;
                _listSolution = new List<Solution>();
                try
                {
                    ////根据xClassConfig的Name获取根节点
                    rootNode = xmlDocument.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return null;
                    }

                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;
                        if (sortid.Equals(xe.GetAttribute("Sortid").ToString()))
                        {
                            Solution solution = new Solution();
                            solution.Name = xe.GetAttribute("Name").ToString();
                            solution.Caption = xe.GetAttribute("Caption").ToString();
                            solution.Sortid = Convert.ToInt32(xe.GetAttribute("Sortid"));
                            solution.Number = Convert.ToInt32(xe.GetAttribute("Number"));
                            // 得到solution节点的所有子节点
                            XmlNodeList childNodeList = xe.ChildNodes;
                            solution.Mapping = new List<Mapping>();

                            foreach (XmlNode node in childNodeList)
                            {
                                Mapping mapping = new Mapping();
                                XmlElement element = (XmlElement)node;
                                mapping.VideoMatrixId = element.GetAttribute("VideoMatrixId");
                                mapping.VideoSourceId = element.GetAttribute("VideoSourceId");
                                mapping.Type = element.GetAttribute("Type");
                                solution.Mapping.Add(mapping);
                            }
                            _listSolution.Add(solution);
                        }

                    }

                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    reader.Close();
                }

            }
            return _listSolution;
        }

      

        /// <summary>
        ///  根据方案名称获取对应的视频源和视频矩阵的对应关系
        /// </summary>
        /// <param name="name">方案名称</param>
        /// <param name="configFile">配置文件的路径</param>
        /// <returns></returns>
        public static List<Solution> GetAllSolution()
        {
            if (System.IO.File.Exists(_solutionFilePath))
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(_solutionFilePath, settings);
                xmlDoc.Load(reader);

                string rootName = "Solution-List";

                XmlNode rootNode = null;
                _listSolution = new List<Solution>();
                try
                {
                    ////根据xClassConfig的Name获取根节点
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return null;
                    }

                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;

                        // 得到solution节点的所有子节点
                        XmlNodeList childNodeList = xe.ChildNodes;
                        // solution.Mapping = new List<Mapping>();
                        Solution solution = new Solution();
                        solution.Mapping = new List<Mapping>();
                        solution.Name = xe.GetAttribute("Name").ToString();
                        solution.Caption = xe.GetAttribute("Caption").ToString();
                        solution.Sortid = Convert.ToInt32(xe.GetAttribute("Sortid"));
                        solution.Number = Convert.ToInt32(xe.GetAttribute("Number"));
                        solution.Clicks = Convert.ToInt32(xe.GetAttribute("Clicks"));

                        foreach (XmlNode node in childNodeList)
                        {

                            XmlElement element = (XmlElement)node;

                            Mapping mapping = new Mapping();
                            mapping.VideoSourceId = element.GetAttribute("VideoSourceId");
                            mapping.VideoMatrixId = element.GetAttribute("VideoMatrixId");

                            solution.Mapping.Add(mapping);

                        }

                        _listSolution.Add(solution);
                    }

                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    reader.Close();
                }

            }
           
            return _listSolution;
        }


        /// <summary>
        /// 获取视频源信息
        /// </summary>
        /// <param name="configFile"></param>
        /// <returns></returns>
        public static List<Item> GetListVideoSource(string configFile, string rootName)
        {
            if (System.IO.File.Exists(configFile))
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(configFile, settings);
                xmlDoc.Load(reader);

                // rootName = "VideoSource";

                XmlNode rootNode = null;
                _listVideoSource = new List<Item>();
                try
                {
                    ////根据xClassConfig的Name获取根节点
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return null;
                    }

                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;
                        Item item = new Item();
                        item.Id = xe.GetAttribute("Id").ToString();
                        item.Caption = xe.GetAttribute("Caption").ToString();
                        if (!string.IsNullOrEmpty(xe.GetAttribute("Sortid").ToString()))
                        {
                            item.Sortid = Convert.ToInt32(xe.GetAttribute("Sortid"));
                        }
                        item.Type = xe.GetAttribute("Type").ToString();
                        if (!string.IsNullOrEmpty(xe.GetAttribute("CameraId").ToString()))
                        {
                            item.CameraId = Convert.ToInt32(xe.GetAttribute("CameraId").ToString());
                        }
                        
                        if (!string.IsNullOrEmpty(xe.GetAttribute("Number").ToString()))
                        {
                            item.Number = Convert.ToInt32(xe.GetAttribute("Number").ToString());
                        }
                        if (!string.IsNullOrEmpty(xe.GetAttribute("Clicks").ToString()))
                        {
                            item.Clicks = Convert.ToInt32(xe.GetAttribute("Clicks").ToString());
                        }
                        
                        
                       
                        _listVideoSource.Add(item);

                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return _listVideoSource;
        }

        /// <summary>
        /// 获取获取矩阵源信息
        /// </summary>
        /// <param name="configFile"></param>
        /// <returns></returns>
        public static List<VideoMatrixItem> GetListVideoMatrixSource(string configFile, string rootName)
        {
            if (System.IO.File.Exists(configFile))
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(configFile, settings);
                xmlDoc.Load(reader);

                // rootName = "VideoSource";

                XmlNode rootNode = null;
                _listVideoMatrixs = new List<VideoMatrixItem>();
                try
                {
                    ////根据xClassConfig的Name获取根节点
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return null;
                    }

                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;
                        VideoMatrixItem item = new VideoMatrixItem();
                        item.Id = xe.GetAttribute("Id").ToString();
                        item.Caption = xe.GetAttribute("Caption").ToString();
                        item.PartName = xe.GetAttribute("PartName").ToString();
                        item.CameraId =Convert.ToInt32 (xe.GetAttribute("CameraId").ToString());
                        _listVideoMatrixs.Add(item);

                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return _listVideoMatrixs;
        }

        /// <summary>
        /// 根据类别id获取视频源信息
        /// </summary>
        /// <param name="configFile"></param>
        /// <returns></returns>
        public static List<Item> GetListVideoBySortId(string configFile, string sortId)
        {
            if (System.IO.File.Exists(configFile))
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(configFile, settings);
                xmlDoc.Load(reader);

                string rootName = "VideoSource";

                XmlNode rootNode = null;
                _listVideoSource = new List<Item>();
                try
                {
                    ////根据xClassConfig的Name获取根节点
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return null;
                    }

                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {

                        XmlElement xe = (XmlElement)childNode;
                        if (sortId.Equals(xe.GetAttribute("Sortid")))
                        {
                            Item item = new Item();
                            item.Id = xe.GetAttribute("Id").ToString();
                            item.Caption = xe.GetAttribute("Caption").ToString();
                            if (!string.IsNullOrEmpty(xe.GetAttribute("Sortid").ToString()))
                            {
                                item.Sortid = Convert.ToInt32(xe.GetAttribute("Sortid"));
                            }
                            item.Type = xe.GetAttribute("Type").ToString();
                            if (!string.IsNullOrEmpty(xe.GetAttribute("CameraId").ToString()))
                            {
                                item.CameraId = Convert.ToInt32(xe.GetAttribute("CameraId").ToString());
                            }
                            if (!string.IsNullOrEmpty(xe.GetAttribute("Number").ToString()))
                            {
                                item.Number = Convert.ToInt32(xe.GetAttribute("Number").ToString());
                            }
                            if (!string.IsNullOrEmpty(xe.GetAttribute("Clicks").ToString()))
                            {
                                item.Clicks = Convert.ToInt32(xe.GetAttribute("Clicks").ToString());
                            }
                            _listVideoSource.Add(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return _listVideoSource;
        }

        /// <summary>
        /// 获取类别信息
        /// </summary>
        /// <returns></returns>
        public static List<Sort> GetSorts(bool isAll)
        {
            if (System.IO.File.Exists(GetSortsFilePath()))
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(GetSortsFilePath(), settings);
                xmlDoc.Load(reader);

                string rootName = "Sorts";

                XmlNode rootNode = null;
                List<Sort> listSorts = new List<Sort>();
                try
                {
                    ////根据xClassConfig的Name获取根节点
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return null;
                    }

                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;
                        Sort sort = new Sort();
                        if (isAll)
                        {
                            sort.Id = Convert.ToInt32(xe.GetAttribute("Id"));
                            sort.Caption = xe.GetAttribute("Caption").ToString();
                            listSorts.Add(sort);
                            break;
                        }
                        else
                        {
                            
                                sort.Id = Convert.ToInt32(xe.GetAttribute("Id"));
                                sort.Caption = xe.GetAttribute("Caption").ToString();
                                listSorts.Add(sort);
                           
                        } 

                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return listSorts;
            }
            return null;
        }

        /// <summary>
        /// 修改Solution信息
        /// </summary>
        /// <param name="solutionFilePath"></param>
        /// <param name="solution"></param>
        /// <returns></returns>
        public static bool UpdateSolution(Datas.Solution cSolution)
        {
            if (System.IO.File.Exists(_solutionFilePath) && cSolution != null)
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(_solutionFilePath, settings);
                xmlDoc.Load(reader);

                string rootName = "Solution-List";
                XmlNode rootNode = null;
                try
                {
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return false;
                    }
                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;
                        if (cSolution.Name == xe.GetAttribute("Name").ToString())
                        {
                            xe.SetAttribute("Clicks", cSolution.Clicks.ToString());
                        }

                    }
                    reader.Close();
                    xmlDoc.Save(_solutionFilePath);
                    return true;

                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
            return false;
        }

        /// <summary>
        /// 修改视频信号信息
        /// </summary>
        /// <param name="solutionFilePath"></param>
        /// <param name="solution"></param>
        /// <returns></returns>
        public static bool UpdateItem(Datas.Item cItem, string configFile)
        {
            if (System.IO.File.Exists(configFile) && cItem != null)
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(configFile, settings);
                xmlDoc.Load(reader);

                string rootName = "VideoSource";
                XmlNode rootNode = null;
                try
                {
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return false;
                    }
                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;
                        if (cItem.Id == xe.GetAttribute("Id").ToString())
                        {
                            xe.SetAttribute("Clicks", cItem.Clicks.ToString());
                        }

                    }
                    reader.Close();
                    xmlDoc.Save(configFile);
                    return true;

                }
                catch (Exception ex)
                {
                    CPPEI.Coolzon.Common.Logger.Error(string.Format("UpdateItem to file:{0} error, ex:{1}", configFile, ex));
                    return false;
                    //throw ex;
                }

            }
            return false;
        }

        /// <summary>
        /// 添加Solution信息
        /// </summary>
        /// <param name="solutionFilePath"></param>
        /// <param name="oSolution"></param>
        /// <param name="cSolution"></param>
        /// <returns></returns>
        public static bool AddSolution(Datas.Solution cSolution)
        {
            if (System.IO.File.Exists(_solutionFilePath) && cSolution != null)
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(_solutionFilePath, settings);
                xmlDoc.Load(reader);

                string rootName = "Solution-List";
                XmlNode rootNode = null;
                try
                {
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return false;
                    }

                    //创建新的方案，将配置信息写入方案中
                    XmlElement createXe = xmlDoc.CreateElement("Solution");
                    createXe.SetAttribute("Name", cSolution.Name);
                    createXe.SetAttribute("Caption", cSolution.Caption);
                    createXe.SetAttribute("Sortid", cSolution.Sortid.ToString());
                    createXe.SetAttribute("Number", cSolution.Number.ToString());
                    createXe.SetAttribute("Clicks", cSolution.Clicks.ToString());
                    foreach (Datas.Mapping mapping in cSolution.Mapping)
                    {
                        XmlElement mapXe = xmlDoc.CreateElement("Mapping");
                        mapXe.SetAttribute("VideoSourceId", mapping.VideoSourceId);
                        mapXe.SetAttribute("VideoMatrixId", mapping.VideoMatrixId);
                        mapXe.SetAttribute("Type", mapping.Type);
                        createXe.AppendChild(mapXe);
                    }
                    rootNode.AppendChild(createXe);
                    reader.Close();
                    xmlDoc.Save(_solutionFilePath);
                    return true;

                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return false;
        }

        /// <summary>
        /// 删除Solution信息
        /// </summary>
        /// <param name="solutionFilePath"></param>
        /// <param name="oSolution"></param>
        /// <param name="cSolution"></param>
        /// <returns></returns>
        public static bool DeleteSolution(Datas.Solution cSolution)
        {
            if (System.IO.File.Exists(_solutionFilePath) && cSolution != null)
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(_solutionFilePath, settings);
                xmlDoc.Load(reader);

                string rootName = "Solution-List";
                XmlNode rootNode = null;
                try
                {
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return false;
                    }
                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;

                        if (cSolution.Name == xe.GetAttribute("Name").ToString() && cSolution.Caption == xe.GetAttribute("Caption").ToString())
                        {
                            rootNode.RemoveChild(childNode);
                        }

                    }

                    reader.Close();
                    xmlDoc.Save(_solutionFilePath);
                    return true;

                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
            return false;
        }

        /// <summary>
        /// 获取最后一次矩阵上的视频信息
        /// </summary>
        /// <returns></returns>
        public static List<Mapping> GetLastMatrixSource()
        {
            if (System.IO.File.Exists(GetLastMatrixSourceFilePath()))
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(GetLastMatrixSourceFilePath(), settings);
                xmlDoc.Load(reader);

                string rootName = "Mappings";

                XmlNode rootNode = null;
                List<Mapping> listMappings = new List<Mapping>();
                try
                {
                    ////根据xClassConfig的Name获取根节点
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return null;
                    }

                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;

                        Mapping mapping = new Mapping();
                        mapping.VideoSourceId = xe.GetAttribute("VideoSourceId");
                        mapping.VideoMatrixId = xe.GetAttribute("VideoMatrixId");
                        listMappings.Add(mapping);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return listMappings;
            }
          
            return null;
        }

        /// <summary>
        /// 更新最后一次矩阵上的视频信息
        /// </summary>
        /// <returns></returns>
        public static void UpdateLastMatrixSource( List<Mapping> mappings)
        {
            if (System.IO.File.Exists(GetLastMatrixSourceFilePath()) && mappings != null)
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments = true;
                XmlReader reader = XmlReader.Create(GetLastMatrixSourceFilePath(), settings);
                xmlDoc.Load(reader);

                string rootName = "Mappings";
                XmlNode rootNode = null;
                try
                {
                    rootNode = xmlDoc.SelectSingleNode("./" + rootName);

                    if (rootNode == null || rootNode.ChildNodes == null)
                    {
                        return;
                    }
                    foreach (XmlNode childNode in rootNode.ChildNodes)
                    {
                        XmlElement xe = (XmlElement)childNode;

                        foreach (Mapping map in mappings)
                        {
                            if (map.VideoMatrixId == xe.GetAttribute("VideoMatrixId").ToString())
                            {
                                xe.SetAttribute("VideoSourceId", map.VideoSourceId.ToString());
                                break;
                            }
                        }
                    }
                    reader.Close();
                    xmlDoc.Save(GetLastMatrixSourceFilePath());

                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
            
               
           
        }


        /// <summary>
        /// 获取solution.xml文件的地址
        /// </summary>
        /// <returns></returns>
        public static string GetSolutionFilePath()
        {
            return string.Format("{0}\\coolzon\\tools\\vmtool\\V{1}\\{2}",
              Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
              typeof(VMSolutionUntil).Assembly.GetName().Version.ToString(3),
              "solution.xml");
           
        }

        /// </summary>
        /// 获取VideoMatrix.xml文件的地址
        /// </summary>
        /// <returns></returns>
        public static string GetVideoMatrixFilePath()
        {
            return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Configs\\VideoMatrix.xml");
        }

        /// </summary>
        /// 获取VideoSource.xml文件的地址
        /// </summary>
        /// <returns></returns>
        public static string GetVideoSourceFilePath()
        {
            return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Configs\\VideoSource.xml");
        }

        /// </summary>
        /// 获取Sorts.xml文件的地址
        /// </summary>
        /// <returns></returns>
        public static string GetSortsFilePath()
        {
            return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "Configs\\Sorts.xml");
        }

        /// </summary>
        /// 获取LastMatrixSource.xml文件的地址
        /// </summary>
        /// <returns></returns>
        public static string GetLastMatrixSourceFilePath()
        {
            return string.Format("{0}\\coolzon\\tools\\vmtool\\V{1}\\{2}",
                Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                typeof(VMSolutionUntil).Assembly.GetName().Version.ToString(3),
                "LastMatrixSource.xml");
        }
    }
}
